import http from './http';
import { requestWithRetry } from '@/utils/retry';

// 客户习惯分析API
export const customerHabitsAPI = {
  // 获取客户习惯分析数据
  getCustomerHabits: async (params?: { startDate?: string; endDate?: string }) => {
    try {
      // 使用重试机制获取客户习惯分析数据
      const response = await requestWithRetry(
        () => http.get('/reports/customer-habits', { params }),
        3, // 最多重试3次
        1000 // 基础延迟1秒
      );
      
      return {
        success: true,
        data: response.data
      };
    } catch (error: any) {
      return {
        success: false,
        data: null,
        message: error.message || '获取客户习惯分析数据失败'
      };
    }
  }
};

export default customerHabitsAPI;